/**
 * SiteInfoAction.java
 * 
 * 
 * lssrc.com
 * 2013-01-14
 */
package com.lssrc.pams.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.lssrc.pams.domain.SiteInfo;
import com.lssrc.pams.service.SiteInfoService;
import com.opensymphony.xwork2.ActionSupport;

@Controller("siteInfoAction")
@Scope("prototype")
public class SiteInfoAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private SiteInfoService siteInfoService;
	private String msg;
	private Integer id;
	private String name;
	private String target;
	private String value;
	private String infoGroup;
	private List<SiteInfo> siteInfos;

	public String add() {
		if (siteInfoService.save(new SiteInfo(name, target, value, infoGroup))) {
			msg = "[{result:'success'}]";
		} else {
			msg = "[{result:'error'}]";
		}
		return SUCCESS;
	}

	public String delete() {
		if (siteInfoService.delete(new SiteInfo(id))) {
			msg = "[{result:'success'}]";
		} else {
			msg = "[{result:'error'}]";
		}
		return SUCCESS;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getInfoGroup() {
		return infoGroup;
	}

	public void setInfoGroup(String infoGroup) {
		this.infoGroup = infoGroup;
	}

	public List<SiteInfo> getSiteInfos() {
		return siteInfos;
	}

	public void setSiteInfos(List<SiteInfo> siteInfos) {
		this.siteInfos = siteInfos;
	}

	@Resource
	public void setSiteInfoService(SiteInfoService siteInfoService) {
		this.siteInfoService = siteInfoService;
	}

}
